// register.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    mobile:'',
    name:'',
    password:'',
    nodes: [{
      name: 'br'
    }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '自定义转发标题',
      path: '/page/user?id=123'
    }
  },
 
    tapName: function(event) {
      console.log(event)
    },
    formSubmit: function (e) {
     var data = e.detail.value;
     var app = getApp();
     wx.request({
       url: app.globalData.domain +'/askforum/login',
       method: 'POST',
       header: {
         'content-type': 'application/x-www-form-urlencoded'
       },
       dataType: 'json',
       data: {
        // name:data.Name,
        password:data.password,
        phone:data.phone,
       },
       success: function (res) {
         console.log(res)
         if(res.data.code ==200){
           wx.setStorage({
             key: "userid",
             data: res.data.userinfo.id,
             success: function (data) {

             }
           })
         }else{
           console.log(res.data.msg)
         }
        
       }
     })
    },
    bindinputPhone: function(e){
        this.setData({
          mobile:e.detail.value
        })
    },
    bindinputName: function (e) {
      this.setData({
        name: e.detail.value
      })
    },
    bindinputPassword: function (e) {
      this.setData({
        password: e.detail.value
      })
    }
  
})